$def with (fname, flines)
<html>
<head>
    <title>Test code prettify</title>
    <script type="text/javascript" src="/static/prettify.js"></script>
    <script type="text/javascript" src="/static/jquery.min.js"></script>
    <script type="text/javascript">
        var jq = jQuery;
        jq(function() {
            prettyPrint();

            // ref: http://stackoverflow.com/questions/1219860?tab=votes#tab-top
            function htmlEncode(s) {
                return jq("<div/>").text(s).html();
            }
            function htmlDecode(s) {
                return jq("<div/>").html(s).text();
            }

            jq("span.pln").each(function(idx, el) {
                el = jq(el);

                // split plain words
                var parts = htmlDecode(el.html()).match(/\S+|\s+/g);
                if (parts == null)
                    parts = [];
                for (var i = 0; i < parts.length; ++i) {
                    if (/\s+/.test(parts[i]))
                        parts[i] = "<span>" + parts[i] + "</span>";
                    else {
                        parts[i] = "<span class='plnWord " + parts[i] + "'>" + parts[i] + "</span>";
                    }
                }
                parts = parts.join("");

                // line end if next elem is the line no
                if (el.next().hasClass("lineno"))
                    parts += "<br>";
                el.html(parts);
            });

            var lastHighLight = null;
            jq("span.plnWord").click(function() {
                if (lastHighLight)
                    lastHighLight.removeClass("hl");
                lastHighLight = jq("." + jq(this).text()).filter(".plnWord").addClass("hl");
            });
        });
    </script>
    <link href="/static/prettify.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
    span.plnWord:hover {
        color: red;
        cursor: pointer;
    }
    .hl {
        background-color: yellow;
    }
    </style>
</head>
<body>
$code:
    if len(fname.split(".")) == 2:
        lang = "lang-%s" % fname.split(".")[1]
    else:
        lang = ""
<pre id="codes" class="prettyprint $lang">
$code:
    lineno_pat = ' %%0%dd ' % len(str(len(flines)))
$for line in flines:
    $ lineno = lineno_pat % loop.index
    <span class="lineno nocode"><a name=$loop.index href="#$loop.index">$lineno</a> </span>$line.rstrip()
</pre>
</div>
</body>
</html>
